package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TBase;
import com.ruoyi.system.service.ITBaseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 数据统计Controller
 * 
 * @author wzy
 * @date 2024-05-08
 */
@RestController
@RequestMapping("/system/base")
public class TBaseController extends BaseController
{
    @Autowired
    private ITBaseService tBaseService;

    /**
     * 查询数据统计列表
     */
    @PreAuthorize("@ss.hasPermi('system:base:list')")
    @GetMapping("/list")
    public TableDataInfo list(TBase tBase)
    {
        startPage();
        List<TBase> list = tBaseService.selectTBaseList(tBase);
        return getDataTable(list);
    }

    /**
     * 导出数据统计列表
     */
    @PreAuthorize("@ss.hasPermi('system:base:export')")
    @Log(title = "数据统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TBase tBase)
    {
        List<TBase> list = tBaseService.selectTBaseList(tBase);
        ExcelUtil<TBase> util = new ExcelUtil<TBase>(TBase.class);
        util.exportExcel(response, list, "数据统计数据");
    }

    /**
     * 获取数据统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:base:query')")
    @GetMapping(value = "/{baseId}")
    public AjaxResult getInfo(@PathVariable("baseId") Integer baseId)
    {
        return success(tBaseService.selectTBaseByBaseId(baseId));
    }

    /**
     * 新增数据统计
     */
    @PreAuthorize("@ss.hasPermi('system:base:add')")
    @Log(title = "数据统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TBase tBase)
    {
        return toAjax(tBaseService.insertTBase(tBase));
    }

    /**
     * 修改数据统计
     */
    @PreAuthorize("@ss.hasPermi('system:base:edit')")
    @Log(title = "数据统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TBase tBase)
    {
        return toAjax(tBaseService.updateTBase(tBase));
    }

    /**
     * 删除数据统计
     */
    @PreAuthorize("@ss.hasPermi('system:base:remove')")
    @Log(title = "数据统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{baseIds}")
    public AjaxResult remove(@PathVariable Integer[] baseIds)
    {
        return toAjax(tBaseService.deleteTBaseByBaseIds(baseIds));
    }
}
